]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
st: Use StAdjustment's new transition API
authorFlorian Müllner <fmuellner@gnome.org>
Fri, 2 Aug 2019 15:04:42 +0000 (17:04 +0200)
committerFlorian Müllner <fmuellner@gnome.org>
Wed, 7 Aug 2019 16:40:47 +0000 (18:40 +0200)
Now that the adjustment itself can be used to track its transitions,
do that for animating the scroll bar handle.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/669

src/st/st-scroll-bar.c

index 9d0ca819f175ccb4fdea346bbdbc786ef8b00bae..3f118b0991ce00209b3088ca0bf055000459554c 100644 (file)
@@ -66,8 +66,6 @@ struct _StScrollBarPrivate
   guint             paging_source_id;
   guint             paging_event_no;
 
-  ClutterTransition *paging_animation;
-
   guint             vertical : 1;
 };
 
@@ -670,18 +668,11 @@ handle_button_press_event_cb (ClutterActor       *actor,
   return TRUE;
 }
 
-static void
-animation_completed_cb (ClutterTransition *animation,
-                        gboolean           is_finished,
-                        StScrollBarPrivate *priv)
-{
-  g_clear_object (&priv->paging_animation);
-}
-
 static gboolean
 trough_paging_cb (StScrollBar *self)
 {
   StScrollBarPrivate *priv = st_scroll_bar_get_instance_private (self);
+  g_autoptr (ClutterTransition) transition = NULL;
   StSettings *settings;
   gfloat handle_pos, event_pos, tx, ty;
   gdouble value, new_value;
@@ -772,26 +763,22 @@ trough_paging_cb (StScrollBar *self)
       new_value = value - page_increment;
     }
 
-  if (priv->paging_animation)
-    {
-      clutter_timeline_stop (CLUTTER_TIMELINE (priv->paging_animation));
-    }
+  /* Stop existing transition, if one exists */
+  st_adjustment_remove_transition (priv->adjustment, "value");
 
   settings = st_settings_get ();
   g_object_get (settings, "slow-down-factor", &slow_down_factor, NULL);
 
   /* FIXME: Creating a new transition for each scroll is probably not the best
   * idea, but it's a lot less involved than extending the current animation */
-  priv->paging_animation = g_object_new (CLUTTER_TYPE_PROPERTY_TRANSITION,
-                                         "animatable", priv->adjustment,
-                                         "property-name", "value",
-                                        "interval", clutter_interval_new (G_TYPE_DOUBLE, value, new_value),
-                                         "duration", (guint)(PAGING_SUBSEQUENT_REPEAT_TIMEOUT * slow_down_factor),
-                                         "progress-mode", mode,
-                                         NULL);
-  g_signal_connect (priv->paging_animation, "stopped",
-                    G_CALLBACK (animation_completed_cb), priv);
-  clutter_timeline_start (CLUTTER_TIMELINE (priv->paging_animation));
+  transition = g_object_new (CLUTTER_TYPE_PROPERTY_TRANSITION,
+                             "property-name", "value",
+                             "interval", clutter_interval_new (G_TYPE_DOUBLE, value, new_value),
+                             "duration", (guint)(PAGING_SUBSEQUENT_REPEAT_TIMEOUT * slow_down_factor),
+                             "progress-mode", mode,
+                             "remove-on-complete", TRUE,
+                             NULL);
+  st_adjustment_add_transition (priv->adjustment, "value", transition);
 
   return ret;
 }